<template>
	<!-- 根目录 -->
	<view class="content">
		<!-- 搜索 -->
		<search></search>
		<!-- 轮播图 -->
		<swiper class="swiper" circular indicator-dots indicator-color="raga(255,255,255,0.5)" indicator-active-color="#fff">
			<swiper-item v-for="(item,index) in swiperData" :key="index">
				<image :src="item.image_src" mode=""></image>
			</swiper-item>
		</swiper>
		<!-- 分类 -->
		<view class="category">
			<image :src="item.image_src" mode="" v-for="(item,index) in cateGoryData" :key="index"></image>
		</view>
		<!-- 导航图片 -->
		<view class="nav-image" v-for="(item,index) in floorData" :key="index">
			<image :src="item.floor_title.image_src" mode=""></image>
			<view class="inner">
				<image :src="item.product_list[0].image_src" mode=""></image>
				<view class="right">
					<image v-for="(ele,index) in item.product_list" :key="index" v-if="index" :src="ele.image_src" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import search from '@/components/searchLink'
	export default {
		components:{
			 search
		},
		data() {
			return {
				// 轮播图
				swiperData: [],
				// 分类
				cateGoryData:[],
				// 导航图片楼层
				floorData:[]
			}
		},
		onLoad() {
			this.getSwiper()
			this.getCategory()
			this.getFloor()
			
		},
		methods: {
			// 获取轮播图
			getSwiper() {
				uni.request({
					url: 'https://www.uinav.com/api/public/v1/home/swiperdata', //仅为示例，并非真实接口地址。
					success: (res) => {
						let {
							meta,
							message
						} = res.data
						if (meta.status === 200) {
							this.swiperData = message
						}
					}
				});
			},
			// 获取分类
			getCategory(){
				uni.request({
					url: 'https://www.uinav.com/api/public/v1/home/catitems', //仅为示例，并非真实接口地址。
					success: (res) => {
						let {
							meta,
							message
						} = res.data
						if (meta.status === 200) {
							// console.log('分类',res)
							this.cateGoryData = message
						}
					}
				});
			},
			getFloor(){
				uni.request({
					url: 'https://www.uinav.com/api/public/v1/home/floordata', //仅为示例，并非真实接口地址。
					success: (res) => {
						let {
							meta,
							message
						} = res.data
						if (meta.status === 200) {
							this.floorData = message
							console.log(message)
						}
						this.floorData.forEach(item=>{
							console.log('我看看',item.product_list[0].image_src)
						})
					}
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.content {
		box-sizing: border-box;
		// 轮播图区域
		.swiper {
			swiper-item {
				image {
					width: 100%;
					height: 340rpx;
				}
			}
		}

		// 分类区域
		.category {
			height: 194rpx;
			display: flex;
			align-items: center;
			justify-content: space-around;

			image {
				width: 128rpx;
				height: 140rpx;
			}
		}

		// 导航图片区域
		.nav-image {
			>image {
				width: 100%;
				height: 88rpx;
				margin-top: 10rpx;
			}

			.inner {
				display: flex;
				padding: 20rpx 17rpx;

				>image {
					width: 232rpx;
					height: 386rpx;
				}

				.right {
					display: flex;
					flex-wrap: wrap;
					flex: 1;
					image {
						width: 232rpx;
						height: 188rpx;
						margin-left: 10rpx;
					}
				}
			}
		}
	}
</style>
